require('../../assets/css/reset.css')
require('../../assets/css/normalize.css')
require('../../assets/iconf/iconfont.css')
require('./myBadge.less')

let axios = require('axios')
// 获取登录时储存的用户信息
let user = JSON.parse(localStorage.getItem('login'))
// 设置axios请求头,添加token
axios.defaults.headers.authorization = "Bearer " + user.token;

let back = document.querySelector('.back')
let badge = document.querySelector('.badge')
let box = document.querySelector('.box')
let mask = document.querySelector('.mask')

box.forEach(function(item,index){
    item.addEventListener('click',function(){
        mask.className = 'mask'
    })
})
// axios.get('http://47.96.154.185:3701/api/exercise/badge')
// .then(function(res){
//     if(res.data.data.errno == 0){
//         res.data.data.forEach(function(item,index){
//             let div = document.createElement('div')
//             div.className = 'box'
//             div.innerHTML = `
//             <img class="badgeImg" src="../../assets/imgs/mybadge01.jpg" alt="">
//                 <div class="badgeText">连续训练天数</div>
//             `
//             badge.appendChild(div)
//         })
//     }
// })

back.addEventListener('click',function(){
    history.go(-1)
})
  
mask.addEventListener('click',function(event){
    console.log(event);
    if(event.target.className == 'mask'){
        mask.style.display = 'none'
    }

})

